/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Donnees;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author mizho
 */
@Entity
@Table(name = "commentaire")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Commentaire.findAll", query = "SELECT c FROM Commentaire c"),
    @NamedQuery(name = "Commentaire.findByIdcomment", query = "SELECT c FROM Commentaire c WHERE c.idcomment = :idcomment"),
    @NamedQuery(name = "Commentaire.findByMessage", query = "SELECT c FROM Commentaire c WHERE c.message = :message"),
    @NamedQuery(name = "Commentaire.findByDatecomment", query = "SELECT c FROM Commentaire c WHERE c.datecomment = :datecomment")})
public class Commentaire implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "idcomment")
    private String idcomment;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10000)
    @Column(name = "message")
    private String message;
    @Basic(optional = false)
    @NotNull
    @Column(name = "datecomment")
    @Temporal(TemporalType.DATE)
    private Date datecomment;
    @JoinColumn(name = "idauteur", referencedColumnName = "idutilisateur")
    @ManyToOne(optional = false)
    private Utilisateur idauteur;
    @JoinColumn(name = "td", referencedColumnName = "idtd")
    @ManyToOne(optional = false)
    private Td td;

    public Commentaire() {
    }

    public Commentaire(String idcomment) {
        this.idcomment = idcomment;
    }

    public Commentaire(String idcomment, String message, Date datecomment) {
        this.idcomment = idcomment;
        this.message = message;
        this.datecomment = datecomment;
    }

    public String getIdcomment() {
        return idcomment;
    }

    public void setIdcomment(String idcomment) {
        this.idcomment = idcomment;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Date getDatecomment() {
        return datecomment;
    }

    public void setDatecomment(Date datecomment) {
        this.datecomment = datecomment;
    }

    public Utilisateur getIdauteur() {
        return idauteur;
    }

    public void setIdauteur(Utilisateur idauteur) {
        this.idauteur = idauteur;
    }

    public Td getTd() {
        return td;
    }

    public void setTd(Td td) {
        this.td = td;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idcomment != null ? idcomment.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Commentaire)) {
            return false;
        }
        Commentaire other = (Commentaire) object;
        if ((this.idcomment == null && other.idcomment != null) || (this.idcomment != null && !this.idcomment.equals(other.idcomment))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Donnees.Commentaire[ idcomment=" + idcomment + " ]";
    }
    
}
